<%--
  Created by IntelliJ IDEA.
  User: 王琛
  Date: 2021/7/20
  Time: 11:15
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

<html>
<head>
    <title>拍卖行</title>
</head>
<body>
<script>alert('${success}');</script>
<button><a href=" http://localhost:8080/ssm/userequip/house">我的仓库</a></button> <button><a href="http://localhost:8080/ssm/userequip/quchongzhi">充值</a></button>
<button><a href="http://localhost:8080/ssm/auction/query">查询余额</a></button>
<form action="<%=request.getContextPath()%>/auction/select">
    <input type="text" name="equipName">装备名
    <input type="text" name="lPrice">价格下限
    <input type="text" name="hPrice">价格上限
    <input type="submit" value="查询">
</form>

<table class="table">
    <tr><th>id</th><th>装备名</th><th>拥有者</th><th>一口价</th><th>当前竞拍价</th><th>数量</th></tr>
    <c:forEach items="${message}" var="item">
        <tr>
            <td>${item.id}</td>
            <td>${item.equipName}</td>
            <td>${item.userName}</td>
            <td>${item.price}</td>
            <td>${item.currentPrice}</td>
            <td>${item.equipNumber}</td>
            <td><button onclick="buy(${item.id})">购买</button></td>
            <td><button onclick="toedit('${item.id}')">修改</button></td>
        </tr>
    </c:forEach>

</table>
<form id="form" action="<%=request.getContextPath()%>/auction/list" style="text-align: center">
    <input id="index" type="text" name="pageIndex" >
    <input id="size" type="text" name="pageSize" >
    <input id="total" name="size" type="hidden" value="${total}" />
    <input type="submit" value="提交">
</form>
</body>
<script src="https://www.jq22.com/jquery/jquery-1.7.1.js"></script>
<script>
   var toedit = function (id) {
     window.location.href="toedit/"+id;
   }
   function  buy(id) {
     $.ajax({
       //这个地址
       "url":"<%=request.getContextPath()%>/auction/buy" ,
       //这种方式
       "type":"post",
       //传递这样的数据
       "data":{"id":id},
       "dataType":"json",
       "success":function (data){
         console.log(data);
       },
       "error":function (a,b,c) {
         console.log(a);
         console.log(b);
         console.log(c);
       }
     });
   }
</script>
</html>
